<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    /**
     * 获取首页标签列表
     * @throws
     */
    public function getTags()
    {
        $list = model('Icon')->getIconsByType(1);
        $this->success('success', $list);
    }

    /**
     * 获取轮播图
     * @throws
     */
    public function getSliders()
    {
        $imgs = Db::name('ad')->field('title, image')
            ->where([ 'status'=>1, 'position'=>1 ])
            ->order('createtime asc')->select();
        $ret = [];
        foreach ($imgs as $v)
        {
            array_push($ret,$this->siteUrl . $v['image']);
        }
        $this->success('成功', $ret);
    }
}
